package cn.sciento.core.convert.config;

import cn.sciento.core.convert.date.DateConverter;
import cn.sciento.core.convert.date.LocalDateConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ConvertWebMvcConfigurer implements WebMvcConfigurer {
    @Value("${stong.date.converter.enable:true}")
    private boolean enable;

    public void addFormatters(FormatterRegistry registry) {
        if (this.enable) {
            registry.addConverter(new DateConverter());
            registry.addConverter(new LocalDateConverter());
        }
    }
}
